This forum is closed to new posts and
responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:
I found the problem. I was trying to write the function so that it could work in two different ways - with the document I needed passed directly as an argument OR if "nothing" was passed instead then be able to go and find it.
Apparently when you have a NotesDocument defined as an argument to your function, you cannot reassign that object variable. When I declared the target NotesDocument as a local object variable, then both GetDocumentByUNID (NotesDatabase) and GetDocumentByKey (NotesView) worked just as expected.
Looks like I need to brush up on the rules for byref vs byval parameters with respect to notes objects.
Working code:
Function ImpUpdateLetter(letterUNID As String,allowSaveLetter As Boolean) As String
Dim s As New NotesSession
Dim letterDoc As NotesDocument
Dim researchDoc As NotesDocument
Dim researchView As NotesView
Dim researchId As String
Dim sql As String
Dim saveLetter As Boolean
Dim resUnid As String
...
If Len(letterUNID) = 0 Then
Set letterDoc = ws.Currentdocument.Document
Else
Set letterDoc = s.Currentdatabase.Getdocumentbyunid(letterUNID)
End If
resUnid = letterDoc.ResearchRequestID(0)
Set researchView = s.Currentdatabase.Getview("(LU Research By ResReqID)")
Set researchDoc = researchView.GetDocumentByKey(resUnid)
If researchDoc Is Nothing Then
MsgBox "Unable to find research request for this letter (" & resUnid & "). Please submit an IT ticket to report this problem or notify your manager. Thank you.",0,"Programming error."
End
End If
...
Feedback response number WEBB959N9J created by ~Mark Nonjipysterings on 02/25/2013